package com.wzh.controll;

import com.wzh.pojo.Po.Personques;
import com.wzh.pojo.Po.Questions;
import com.wzh.service.Personquesser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/personques")
public class personquestion {
    @Autowired
	private Personquesser personquesser;

	@GetMapping("/getsome")
	@ResponseBody
	public result getsome(@RequestParam int userid){
		System.out.println(userid);
		List<Questions> questions = personquesser.getsome(userid);
		String mes=questions!=null?"查询成功":"查询失败";
		Integer code=questions!=null?200:300;
		return new result(mes,code,questions);
	};

	@PostMapping("/add")
	@ResponseBody
	public result adduser(@RequestBody Personques personques){
		System.out.println(personques);
		boolean flag=personquesser.add(personques);
		String mes=flag!=false?"操作成功":"操作失败";
		Integer code=flag!=false?200:300;
		return new result(mes,code,personques);
	}
	@PostMapping("/delete")
	@ResponseBody
	public result deone(@RequestBody Personques personques){
		System.out.println(personques);
		boolean flag=personquesser.delete(personques);
		String mes=flag!=false?"操作成功":"操作失败";
		Integer code=flag!=false?200:300;
		return new result(mes,code,personques);
	}

}
